how to create conditions in javascript